//
//  RNEaseUIViewController.m
//  app
//
//  Created by 张舰 on 2017/12/11.
//  Copyright © 2017年 Facebook. All rights reserved.
//

#import "RNEaseUIViewController.h"
#import "AppDelegate.h"
#import <EaseUI.h>
#import "RNChatViewController.h"


extern NSDictionary *YxInfo = nil;
extern NSDictionary *OwnerInfo = nil;

@interface RNEaseUIViewController ()


@end

@implementation RNEaseUIViewController

// 将当前类设置为主线程
- (dispatch_queue_t)methodQueue {
  return dispatch_get_main_queue();
}
// 导出模块给 js
RCT_EXPORT_MODULE(RNEaseUI)

// 导出要发送给js端的方法
- (NSArray<NSString *> *) supportedEvents {
  return @[@"receiveMessage"];
}

RCT_EXPORT_METHOD(toEaseUI: (NSString *) chatter yxInfo:(NSDictionary *) yxInfo ownerInfo:(NSDictionary *) ownerInfo) {
  YxInfo = yxInfo;
  OwnerInfo = ownerInfo;
  RNChatViewController *chatController = [[RNChatViewController alloc] initWithConversationChatter:chatter conversationType:EMConversationTypeChat];
  chatController.yxInfo = yxInfo;
  chatController.ownerInfo = ownerInfo;
  AppDelegate *share = (AppDelegate *)[UIApplication sharedApplication].delegate;
  UINavigationController *navi = ((UINavigationController *) share.window.rootViewController);
  [navi pushViewController:chatController animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
